home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume34 / vesa_lib / part01 next >
Encoding:
Text File  |  1993-01-10  |  18.7 KB  |  1,007 lines

  1. Newsgroups: comp.sources.misc
  2. From: bobp@hal.com (Bob Pendleton)
  3. Subject: v34i105:  vesa_lib - A Simple VESA BIOS interface library., Part01/01
  4. Message-ID: <1993Jan11.040215.4155@sparky.imd.sterling.com>
  5. X-Md4-Signature: 71b5829b11de0d0cf20f5c85da1b3ae3
  6. Date: Mon, 11 Jan 1993 04:02:15 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: bobp@hal.com (Bob Pendleton)
  10. Posting-number: Volume 34, Issue 105
  11. Archive-name: vesa_lib/part01
  12. Environment: MSC7
  13.  
  14. This is the source code for a VESA BIOS version 1.1 interface library
  15. for use with msdos. It compiles under MSC7.  I've included a simple 
  16. demo program as well.  This is all public domain.
  17.  
  18. Bob P.
  19. ----------------------
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then feed it
  22. # into a shell via "sh file" or similar.  To overwrite existing files,
  23. # type "sh file -c".
  24. # Contents:  main.cpp makefile ptypes.h read.me vesa.cpp vesa.h
  25. # Wrapped by kent@sparky on Sun Jan 10 22:08:17 1993
  26. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 1 (of 1)."'
  29. if test -f 'main.cpp' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'main.cpp'\"
  31. else
  32.   echo shar: Extracting \"'main.cpp'\" \(1833 characters\)
  33.   sed "s/^X//" >'main.cpp' <<'END_OF_FILE'
  34. X/*
  35. X
  36. XWritten by: Robert C. Pendleton
  37. X
  38. XPlaced in the public domain by the author.
  39. X
  40. X*/
  41. X
  42. X#include <dos.h>
  43. X#include <conio.h>
  44. X#include <stdio.h>
  45. X#include <memory.h>
  46. X#include "ptypes.h"
  47. X#include "vesa.h"
  48. X
  49. X//---------------------------------------------------
  50. X
  51. Xstatic uint8 _huge *screen = (uint8 *) 0xA0000000L;
  52. XvesaInfo info;
  53. XvesaModeInfo modeInfo;
  54. X
  55. X//---------------------------------------------------
  56. X
  57. Xvoid
  58. Xmain()
  59. X{
  60. X    int16 oldMode;
  61. X    uint8 _huge *scrnAddr;
  62. X    int16 i;
  63. X    int16 j;
  64. X    uint32 pixel;
  65. X    uint32 pixels[] =
  66. X    {
  67. X        0x00000000l,
  68. X        0x01010101l,
  69. X        0x02020202l,
  70. X        0x03030303l,
  71. X        0x04040404l,
  72. X        0x05050505l,
  73. X        0x06060606l,
  74. X        0x07070707l,
  75. X        0x08080808l
  76. X    };
  77. X
  78. X
  79. X    getVesaMode(&oldMode);
  80. X
  81. X    setVesaMode(g320x200);
  82. X    setVesaScanLineLength(1024);
  83. X
  84. X    setVGAColor(0, 0xf0, 0xf0, 0xf0);
  85. X    setVGAColor(1, 0x00, 0x00, 0xff);
  86. X    setVGAColor(2, 0x00, 0xff, 0x00);
  87. X    setVGAColor(3, 0x00, 0xff, 0xff);
  88. X    setVGAColor(4, 0xff, 0x00, 0x00);
  89. X    setVGAColor(5, 0xff, 0x00, 0xff);
  90. X    setVGAColor(6, 0xff, 0xff, 0x00);
  91. X    setVGAColor(7, 0xff, 0xff, 0xff);
  92. X    setVGAColor(8, 0x3c, 0x3c, 0x3c);
  93. X
  94. X
  95. Xtop:
  96. X    for(i = 0; i < 16; i++)
  97. X    {
  98. X        setVesaWinAAddr(i);
  99. X        memset(screen, i%8, 0x8000);
  100. X        memset(screen + 0x8000l, i%8, 0x8000);
  101. X    }
  102. X
  103. X    for(i = 0; i < 640; i += 10)
  104. X    {
  105. X        setVesaDisplayStart(0, i);
  106. X    }
  107. X
  108. X    for(i = 0; i < 16; i++)
  109. X    {
  110. X        setVesaWinAAddr(i);
  111. X        scrnAddr = screen;
  112. X        for(j = 0; j < 64; j++)
  113. X        {
  114. X            *(scrnAddr +   0) = 8;
  115. X            *(scrnAddr +  32) = 8;
  116. X            *(scrnAddr +  64) = 8;
  117. X            *(scrnAddr +  96) = 8;
  118. X            *(scrnAddr + 128) = 8;
  119. X            *(scrnAddr + 160) = 8;
  120. X            *(scrnAddr + 192) = 8;
  121. X            *(scrnAddr + 224) = 8;
  122. X            *(scrnAddr + 256) = 8;
  123. X            *(scrnAddr + 288) = 8;
  124. X            *(scrnAddr + 320) = 8;
  125. X
  126. X            scrnAddr += 1024;
  127. X        }
  128. X    }
  129. X
  130. X    for(i = 0; i < 1024; i += 8)
  131. X    {
  132. X        setVesaDisplayStart(i, 0);
  133. X    }
  134. X
  135. X    setVesaDisplayStart(0, 0);
  136. X    if(!_kbhit())goto top;
  137. X    while(!_kbhit());_getch();
  138. X    setVesaMode(oldMode);
  139. X}
  140. END_OF_FILE
  141.   if test 1833 -ne `wc -c <'main.cpp'`; then
  142.     echo shar: \"'main.cpp'\" unpacked with wrong size!
  143.   fi
  144.   # end of 'main.cpp'
  145. fi
  146. if test -f 'makefile' -a "${1}" != "-c" ; then 
  147.   echo shar: Will not clobber existing file \"'makefile'\"
  148. else
  149.   echo shar: Extracting \"'makefile'\" \(470 characters\)
  150.   sed "s/^X//" >'makefile' <<'END_OF_FILE'
  151. X#
  152. X# Microsoft C 7.00 Makefile
  153. X#
  154. X
  155. XCDEFS    = /DMSC
  156. XDEBUG   = 
  157. XCFLAGS    = /nologo /O /FPa /AH $(CDEFS) $(DEBUG)
  158. XCC      = cl
  159. X
  160. X#
  161. X# standard headers
  162. X#
  163. X
  164. XDEF = ptypes.h vesa.h
  165. X
  166. X#
  167. X# implicit compilation rule
  168. X#
  169. X
  170. X.cpp.obj:
  171. X    $(CC) /c $(CFLAGS) $*.cpp
  172. X
  173. Xall: main.exe
  174. X
  175. Xmain.exe : main.obj vesa.obj
  176. X    link /STACK:0x2000 main.obj+vesa.obj;
  177. X
  178. X#
  179. X# header dependencies
  180. X#
  181. X
  182. Xmain.obj: main.cpp $(DEF)
  183. Xvesa.obj: vesa.cpp $(DEF)
  184. X
  185. X#
  186. X# clean up 
  187. X#
  188. Xclean:
  189. X    -rm *.map
  190. X    -rm *.bak
  191. X    -rm *.obj
  192. X    -rm *.exe
  193. X
  194. X
  195. END_OF_FILE
  196.   if test 470 -ne `wc -c <'makefile'`; then
  197.     echo shar: \"'makefile'\" unpacked with wrong size!
  198.   fi
  199.   # end of 'makefile'
  200. fi
  201. if test -f 'ptypes.h' -a "${1}" != "-c" ; then 
  202.   echo shar: Will not clobber existing file \"'ptypes.h'\"
  203. else
  204.   echo shar: Extracting \"'ptypes.h'\" \(531 characters\)
  205.   sed "s/^X//" >'ptypes.h' <<'END_OF_FILE'
  206. X/*
  207. X
  208. XWritten by: Robert C. Pendleton
  209. X
  210. XPlaced in the public domain by the author.
  211. X
  212. X*/
  213. X
  214. X#ifndef _PTYPES_H_
  215. X#define _PTYPES_H_
  216. X
  217. Xtypedef enum {FALSE = 0, TRUE = 1} boolean;
  218. X
  219. X/*
  220. X
  221. XThese define types with unique names for each length.
  222. XThey make it easier to port other environments.
  223. X
  224. X*/
  225. X
  226. Xtypedef signed char        int8;
  227. Xtypedef signed short int    int16;
  228. Xtypedef signed long int        int32;
  229. X
  230. Xtypedef unsigned char        uint8;
  231. Xtypedef unsigned short int    uint16;
  232. Xtypedef unsigned long int    uint32;
  233. X
  234. Xtypedef float            float32;
  235. Xtypedef double            float64;
  236. X
  237. X#endif
  238. END_OF_FILE
  239.   if test 531 -ne `wc -c <'ptypes.h'`; then
  240.     echo shar: \"'ptypes.h'\" unpacked with wrong size!
  241.   fi
  242.   # end of 'ptypes.h'
  243. fi
  244. if test -f 'read.me' -a "${1}" != "-c" ; then 
  245.   echo shar: Will not clobber existing file \"'read.me'\"
  246. else
  247.   echo shar: Extracting \"'read.me'\" \(568 characters\)
  248.   sed "s/^X//" >'read.me' <<'END_OF_FILE'
  249. XThis is the code for a simple vesa 1.1 interface library, and a simple
  250. Xtest program. 
  251. X
  252. XFor more information about the VESA BIOS extension please contact
  253. XVESA. At the time I wrote this, VESA can be contatcted at:
  254. X
  255. XVideo Electronics Standards Association
  256. X2150 North First Street, Suite 440
  257. XSan Jose, CA 95131-2020
  258. XPhone: (408) 435-0333
  259. XFax:   (408) 535-8225
  260. X
  261. XPublic domain VESA TSRs, documentation, and source code available
  262. Xon many ftp sites.
  263. X
  264. XTo the best of my knowledge, everything in this distribution is in the
  265. Xpublic domain. 
  266. X
  267. X            You're Welcome
  268. X
  269. X                Bob Pendleton
  270. END_OF_FILE
  271.   if test 568 -ne `wc -c <'read.me'`; then
  272.     echo shar: \"'read.me'\" unpacked with wrong size!
  273.   fi
  274.   # end of 'read.me'
  275. fi
  276. if test -f 'vesa.cpp' -a "${1}" != "-c" ; then 
  277.   echo shar: Will not clobber existing file \"'vesa.cpp'\"
  278. else
  279.   echo shar: Extracting \"'vesa.cpp'\" \(8554 characters\)
  280.   sed "s/^X//" >'vesa.cpp' <<'END_OF_FILE'
  281. X/*
  282. X
  283. XWritten by: Robert C. Pendleton
  284. X
  285. XPlaced in the public domain by the author.
  286. X
  287. X*/
  288. X
  289. X#include <dos.h>
  290. X#include <conio.h>
  291. X#include <stdio.h>
  292. X#include "ptypes.h"
  293. X#include "vesa.h"
  294. X
  295. X//---------------------------------------------------
  296. X/*
  297. X    Static Variables
  298. X*/
  299. X
  300. Xstatic union _REGS reg;
  301. Xstatic struct _SREGS sreg;
  302. X
  303. X//---------------------------------------------------
  304. X/*
  305. X*/
  306. X
  307. Xvoid
  308. XsetVGAColor(int16 index, int16 r, int16 g, int16 b)
  309. X{
  310. X   reg.x.ax =0x1010;
  311. X
  312. X   reg.x.bx =index;
  313. X   reg.h.dh =r;
  314. X   reg.h.ch =g;
  315. X   reg.h.cl =b;
  316. X
  317. X   _int86(0x10, ®, ®);
  318. X}
  319. X
  320. X//---------------------------------------------------
  321. X/*
  322. X*/
  323. X
  324. Xvoid
  325. XsetVGAPalette(palette *p)
  326. X{
  327. X   reg.x.ax =0x1012;
  328. X   reg.x.bx =0;
  329. X   reg.x.cx =256;
  330. X
  331. X   sreg.es = _FP_SEG(p);
  332. X   reg.x.dx = _FP_OFF(p);
  333. X
  334. X
  335. X   _int86x(0x10, ®, ®, &sreg);
  336. X}
  337. X
  338. X//---------------------------------------------------
  339. X/*
  340. X*/
  341. X
  342. Xboolean
  343. XgetVesaInfo(vesaInfo *infoPtr)
  344. X{
  345. X      reg.x.ax = 0x4f00;
  346. X
  347. X    sreg.es = _FP_SEG(infoPtr);
  348. X    reg.x.di = _FP_OFF(infoPtr);
  349. X
  350. X        _int86x(0x10, ®, ®, &sreg);
  351. X
  352. X    if(reg.x.ax != 0x004f)
  353. X    {
  354. X        return FALSE;
  355. X    }
  356. X
  357. X    return TRUE;
  358. X}
  359. X
  360. X//---------------------------------------------------
  361. X/*
  362. X*/
  363. X
  364. Xvoid
  365. XprintVesaInfo(FILE *file, vesaInfo *info)
  366. X{
  367. X    int16 *mode;
  368. X
  369. X    fprintf(file, "name=%c%c%c%c\n", info->vesa[0],
  370. X                       info->vesa[1],
  371. X                       info->vesa[2],
  372. X                       info->vesa[3]);
  373. X
  374. X    fprintf(file, "Version %d.%d\n", info->majorMode, info->minorMode);
  375. X    fprintf(file, "Vendor %s\n", info->vendorName);
  376. X    fprintf(file, "Capabilities %lX\n", info->capabilities);
  377. X
  378. X    mode = info->modes;
  379. X    while((*mode) != 0xffff)
  380. X    {
  381. X        fprintf(file, "mode=%x\n", *mode);
  382. X        mode++;
  383. X    }
  384. X    fflush(file);
  385. X}
  386. X
  387. X//---------------------------------------------------
  388. X/*
  389. X*/
  390. X
  391. Xboolean
  392. XgetVesaModeInfo(int16 mode, vesaModeInfo *infoPtr)
  393. X{
  394. X      reg.x.ax = 0x4f01;
  395. X      reg.x.cx = mode;
  396. X
  397. X    sreg.es = _FP_SEG(infoPtr);
  398. X    reg.x.di = _FP_OFF(infoPtr);
  399. X
  400. X        _int86x(0x10, ®, ®, &sreg);
  401. X
  402. X    if(reg.x.ax != 0x004f)
  403. X    {
  404. X        return FALSE;
  405. X    }
  406. X
  407. X    return TRUE;
  408. X}
  409. X
  410. X//---------------------------------------------------
  411. X/*
  412. X*/
  413. X
  414. Xvoid
  415. XprintVesaModeInfo(FILE *file, vesaModeInfo *info)
  416. X{
  417. X    boolean optionalInfo = FALSE;
  418. X
  419. X/* mode attributes */
  420. X
  421. X    if(info->modeAttr & (1<<0))
  422. X    {
  423. X        fprintf(file, "supported\n");
  424. X    }
  425. X    else
  426. X    {
  427. X        fprintf(file, "not supported\n");
  428. X    }
  429. X
  430. X    if(info->modeAttr & (1<<1))
  431. X    {
  432. X        fprintf(file, "optional info\n");
  433. X        optionalInfo = TRUE;
  434. X    }
  435. X    else
  436. X    {
  437. X        fprintf(file, "no optional info\n");
  438. X        optionalInfo = FALSE;
  439. X    }
  440. X
  441. X    if(info->modeAttr & (1<<2))
  442. X    {
  443. X        fprintf(file, "BIOS output\n");
  444. X    }
  445. X    else
  446. X    {
  447. X        fprintf(file, "no BIOS output\n");
  448. X    }
  449. X
  450. X    if(info->modeAttr & (1<<3))
  451. X    {
  452. X        fprintf(file, "color\n");
  453. X    }
  454. X    else
  455. X    {
  456. X        fprintf(file, "monochrome\n");
  457. X    }
  458. X
  459. X    if(info->modeAttr & (1<<4))
  460. X    {
  461. X        fprintf(file, "graphics\n");
  462. X    }
  463. X    else
  464. X    {
  465. X        fprintf(file, "text\n");
  466. X    }
  467. X
  468. X/* window A attributes */
  469. X
  470. X    if(info->windowAAttr & (1<<0))
  471. X    {
  472. X        fprintf(file, "window A exists\n");
  473. X    }
  474. X    else
  475. X    {
  476. X        fprintf(file, "window A does not exist\n");
  477. X    }
  478. X
  479. X    if(info->windowAAttr & (1<<1))
  480. X    {
  481. X        fprintf(file, "window A readable\n");
  482. X    }
  483. X    else
  484. X    {
  485. X        fprintf(file, "window A not readable\n");
  486. X    }
  487. X
  488. X    if(info->windowAAttr & (1<<2))
  489. X    {
  490. X        fprintf(file, "window A writable\n");
  491. X    }
  492. X    else
  493. X    {
  494. X        fprintf(file, "window A not writable\n");
  495. X    }
  496. X
  497. X/* window B attributes */
  498. X
  499. X    if(info->windowBAttr & (1<<0))
  500. X    {
  501. X        fprintf(file, "window B exists\n");
  502. X    }
  503. X    else
  504. X    {
  505. X        fprintf(file, "window B does not exist\n");
  506. X    }
  507. X
  508. X    if(info->windowBAttr & (1<<1))
  509. X    {
  510. X        fprintf(file, "window B readable\n");
  511. X    }
  512. X    else
  513. X    {
  514. X        fprintf(file, "window B not readable\n");
  515. X    }
  516. X
  517. X    if(info->windowBAttr & (1<<2))
  518. X    {
  519. X        fprintf(file, "window B writable\n");
  520. X    }
  521. X    else
  522. X    {
  523. X        fprintf(file, "window B not writable\n");
  524. X    }
  525. X
  526. X/* window attributes */
  527. X
  528. X    fprintf(file, "window granularity=%d\n", info->windowGranularity);
  529. X    fprintf(file, "window size=%d\n", info->windowSize);
  530. X    fprintf(file, "window A start seg=%x\n", info->windowAStartSeg);
  531. X    fprintf(file, "window B start seg=%x\n", info->windowBStartSeg);
  532. X
  533. X    fprintf(file, "positioning function=%p\n", info->posFuncPtr);
  534. X
  535. X    fprintf(file, "bytes/scanline=%d\n", info->bytesPerScanLine);
  536. X
  537. X    if(optionalInfo)
  538. X    {
  539. X        fprintf(file, "width =%d\n", info->width);
  540. X        fprintf(file, "height=%d\n", info->height);
  541. X
  542. X        fprintf(file, "char width =%d\n", (int16)(info->charWidth));
  543. X        fprintf(file, "char height=%d\n", (int16)(info->charHeight));
  544. X
  545. X        fprintf(file, "number of planes=%d\n", (int16)(info->numberOfPlanes));
  546. X        fprintf(file, "bits/pixel=%d\n", (int16)(info->bitsPerPixel));
  547. X        fprintf(file, "number of banks=%d\n", (int16)(info->numberOfBanks));
  548. X
  549. X        fprintf(file, "memory model=%d\n", (int16)(info->memoryModel));
  550. X        fprintf(file, "size of bank=%d\n", (int16)(info->sizeOfBank));
  551. X    }
  552. X
  553. X    fflush(file);
  554. X}
  555. X
  556. X//---------------------------------------------------
  557. X/*
  558. X*/
  559. X
  560. Xboolean
  561. XsetVesaMode(int16 mode)
  562. X{
  563. X      reg.x.ax = 0x4f02;
  564. X      reg.x.bx = mode;
  565. X
  566. X        _int86x(0x10, ®, ®, &sreg);
  567. X
  568. X    if(reg.x.ax != 0x004f)
  569. X    {
  570. X        return FALSE;
  571. X    }
  572. X
  573. X    return TRUE;
  574. X}
  575. X
  576. X//---------------------------------------------------
  577. X/*
  578. X*/
  579. X
  580. Xboolean
  581. XgetVesaMode(int16 *mode)
  582. X{
  583. X      reg.x.ax = 0x4f03;
  584. X
  585. X        _int86x(0x10, ®, ®, &sreg);
  586. X
  587. X      *mode = reg.x.bx;
  588. X
  589. X    if(reg.x.ax != 0x004f)
  590. X    {
  591. X        return FALSE;
  592. X    }
  593. X
  594. X    return TRUE;
  595. X}
  596. X
  597. X//---------------------------------------------------
  598. X/*
  599. X*/
  600. X
  601. Xboolean
  602. XgetVesaStateSize(uint8 flags, int32 *size)
  603. X{
  604. X      reg.x.ax = 0x4f04;
  605. X    reg.h.dl = 0x00;
  606. X    reg.x.cx = flags;
  607. X
  608. X        _int86x(0x10, ®, ®, &sreg);
  609. X
  610. X      *size = ((int32)reg.x.bx) * 64;
  611. X
  612. X    if(reg.x.ax != 0x004f)
  613. X    {
  614. X        return FALSE;
  615. X    }
  616. X
  617. X    return TRUE;
  618. X}
  619. X
  620. X//---------------------------------------------------
  621. X/*
  622. X*/
  623. X
  624. Xboolean
  625. XgetVesaState(uint8 flags, uint8 *buffer)
  626. X{
  627. X      reg.x.ax = 0x4f04;
  628. X    reg.h.dl = 0x01;
  629. X    reg.x.cx = flags;
  630. X
  631. X    sreg.es = _FP_SEG(buffer);
  632. X    reg.x.bx = _FP_OFF(buffer);
  633. X
  634. X        _int86x(0x10, ®, ®, &sreg);
  635. X
  636. X    if(reg.x.ax != 0x004f)
  637. X    {
  638. X        return FALSE;
  639. X    }
  640. X
  641. X    return TRUE;
  642. X}
  643. X
  644. X//---------------------------------------------------
  645. X/*
  646. X*/
  647. X
  648. Xboolean
  649. XsetVesaState(uint8 flags, uint8 *buffer)
  650. X{
  651. X      reg.x.ax = 0x4f04;
  652. X    reg.h.dl = 0x02;
  653. X    reg.x.cx = flags;
  654. X
  655. X    sreg.es = _FP_SEG(buffer);
  656. X    reg.x.bx = _FP_OFF(buffer);
  657. X
  658. X        _int86x(0x10, ®, ®, &sreg);
  659. X
  660. X    if(reg.x.ax != 0x004f)
  661. X    {
  662. X        return FALSE;
  663. X    }
  664. X
  665. X    return TRUE;
  666. X}
  667. X
  668. X//---------------------------------------------------
  669. X/*
  670. X*/
  671. X
  672. Xboolean
  673. XsetVesaWinAAddr(uint16 addr)
  674. X{
  675. X      reg.x.ax = 0x4f05;
  676. X    reg.h.bh = 0x00;
  677. X    reg.h.bl = 0x00;
  678. X    reg.x.dx = addr;
  679. X
  680. X        _int86(0x10, ®, ®);
  681. X
  682. X    if(reg.x.ax != 0x004f)
  683. X    {
  684. X        return FALSE;
  685. X    }
  686. X
  687. X    return TRUE;
  688. X}
  689. X
  690. X//---------------------------------------------------
  691. X/*
  692. X*/
  693. X
  694. Xboolean
  695. XsetVesaWinBAddr(uint16 addr)
  696. X{
  697. X      reg.x.ax = 0x4f05;
  698. X    reg.h.bh = 0x00;
  699. X    reg.h.bl = 0x01;
  700. X    reg.x.dx = addr;
  701. X
  702. X        _int86(0x10, ®, ®);
  703. X
  704. X    if(reg.x.ax != 0x004f)
  705. X    {
  706. X        return FALSE;
  707. X    }
  708. X
  709. X    return TRUE;
  710. X}
  711. X
  712. X//---------------------------------------------------
  713. X/*
  714. X*/
  715. X
  716. Xboolean
  717. XgetVesaWinAAddr(uint16 *addr)
  718. X{
  719. X      reg.x.ax = 0x4f05;
  720. X    reg.h.bh = 0x01;
  721. X    reg.h.bl = 0x00;
  722. X
  723. X        _int86(0x10, ®, ®);
  724. X
  725. X    *addr = reg.x.dx;
  726. X
  727. X    if(reg.x.ax != 0x004f)
  728. X    {
  729. X        return FALSE;
  730. X    }
  731. X
  732. X    return TRUE;
  733. X}
  734. X
  735. X//---------------------------------------------------
  736. X/*
  737. X*/
  738. X
  739. Xboolean
  740. XgetVesaWinBAddr(uint16 *addr)
  741. X{
  742. X      reg.x.ax = 0x4f05;
  743. X    reg.h.bh = 0x01;
  744. X    reg.h.bl = 0x01;
  745. X
  746. X        _int86(0x10, ®, ®);
  747. X
  748. X    *addr = reg.x.dx;
  749. X
  750. X    if(reg.x.ax != 0x004f)
  751. X    {
  752. X        return FALSE;
  753. X    }
  754. X
  755. X    return TRUE;
  756. X}
  757. X
  758. X//---------------------------------------------------
  759. X/*
  760. X*/
  761. X
  762. Xboolean
  763. XsetVesaScanLineLength(uint16 length)
  764. X{
  765. X      reg.x.ax = 0x4f06;
  766. X    reg.h.bl = 0x00;
  767. X    reg.x.cx = length;
  768. X
  769. X        _int86(0x10, ®, ®);
  770. X
  771. X    if(reg.x.ax != 0x004f)
  772. X    {
  773. X        return FALSE;
  774. X    }
  775. X
  776. X    return TRUE;
  777. X}
  778. X
  779. X//---------------------------------------------------
  780. X/*
  781. X*/
  782. X
  783. Xboolean
  784. XgetVesaScanLineLength(uint16 *bytesPerScanLine, 
  785. X              uint16 *pixelsPerScanLine, 
  786. X              uint16 *maxScanLines)
  787. X{
  788. X      reg.x.ax = 0x4f06;
  789. X    reg.h.bl = 0x01;
  790. X
  791. X        _int86(0x10, ®, ®);
  792. X
  793. X    *bytesPerScanLine = reg.x.bx;
  794. X    *pixelsPerScanLine = reg.x.cx;
  795. X    *maxScanLines = reg.x.dx;
  796. X
  797. X    if(reg.x.ax != 0x004f)
  798. X    {
  799. X        return FALSE;
  800. X    }
  801. X
  802. X    return TRUE;
  803. X}
  804. X
  805. X//---------------------------------------------------
  806. X/*
  807. X*/
  808. X
  809. Xboolean
  810. XsetVesaDisplayStart(uint16 pixel, uint16 line)
  811. X{
  812. X      reg.x.ax = 0x4f07;
  813. X    reg.h.bh = 0x00;
  814. X    reg.h.bl = 0x00;
  815. X
  816. X    reg.x.cx = pixel;
  817. X    reg.x.dx = line;
  818. X
  819. X        _int86(0x10, ®, ®);
  820. X
  821. X    if(reg.x.ax != 0x004f)
  822. X    {
  823. X        return FALSE;
  824. X    }
  825. X
  826. X    return TRUE;
  827. X}
  828. X
  829. X//---------------------------------------------------
  830. X/*
  831. X*/
  832. X
  833. Xboolean
  834. XgetVesaDisplayStart(uint16 *pixel, uint16 *line) 
  835. X{
  836. X      reg.x.ax = 0x4f07;
  837. X    reg.h.bh = 0x00;
  838. X    reg.h.bl = 0x01;
  839. X
  840. X        _int86(0x10, ®, ®);
  841. X
  842. X    *pixel = reg.x.cx;
  843. X    *line = reg.x.dx;
  844. X
  845. X    if(reg.x.ax != 0x004f)
  846. X    {
  847. X        return FALSE;
  848. X    }
  849. X
  850. X    return TRUE;
  851. X}
  852. X
  853. X//---------------------------------------------------
  854. X
  855. END_OF_FILE
  856.   if test 8554 -ne `wc -c <'vesa.cpp'`; then
  857.     echo shar: \"'vesa.cpp'\" unpacked with wrong size!
  858.   fi
  859.   # end of 'vesa.cpp'
  860. fi
  861. if test -f 'vesa.h' -a "${1}" != "-c" ; then 
  862.   echo shar: Will not clobber existing file \"'vesa.h'\"
  863. else
  864.   echo shar: Extracting \"'vesa.h'\" \(2626 characters\)
  865.   sed "s/^X//" >'vesa.h' <<'END_OF_FILE'
  866. X/*
  867. X
  868. XWritten by: Robert C. Pendleton
  869. X
  870. XPlaced in the public domain by the author.
  871. X
  872. X*/
  873. X
  874. X#ifndef _VESA_H_
  875. X#define _VESA_H_
  876. X
  877. X/*
  878. X
  879. XVESA graphics driver for 256 color VESA graphic modes. It requires
  880. Xa VESA version 1.1 BIOS.
  881. X
  882. XIt has been tested with a VESA 1.1 BIOS on an ET4000
  883. X
  884. X*/
  885. X
  886. X#include "ptypes.h"
  887. X
  888. X//---------------------------------------------------
  889. X/*
  890. X*/
  891. X
  892. Xtypedef struct {
  893. X    uint8 red;
  894. X    uint8 green;
  895. X    uint8 blue;
  896. X} palette;
  897. X
  898. X
  899. X//---------------------------------------------------
  900. X/*
  901. X*/
  902. X
  903. Xtypedef enum {
  904. X    NONE       = 0x000,
  905. X    g320x200   = 0x013,
  906. X    g640x400   = 0x100,
  907. X    g640x480   = 0x101,
  908. X    g800x600   = 0x103,
  909. X    g1024x768  = 0x105,
  910. X    g1280x1024 = 0x107,
  911. X} vesaMode;
  912. X
  913. X//---------------------------------------------------
  914. X/*
  915. X*/
  916. X
  917. Xtypedef union {
  918. X    struct {
  919. X        uint8 vesa[4];
  920. X        uint8 majorMode;
  921. X        uint8 minorMode;
  922. X        uint8 _far *vendorName;
  923. X        uint32 capabilities;
  924. X        int16 _far *modes;
  925. X    };
  926. X    uint8 filler[512];
  927. X} vesaInfo;
  928. X
  929. X//---------------------------------------------------
  930. X/*
  931. X*/
  932. X
  933. Xtypedef union {
  934. X        struct {
  935. X        uint16 modeAttr;
  936. X        uint8 windowAAttr;
  937. X        uint8 windowBAttr;
  938. X        uint16 windowGranularity;
  939. X        uint16 windowSize;
  940. X        uint16 windowAStartSeg;
  941. X        uint16 windowBStartSeg;
  942. X        uint32 posFuncPtr;
  943. X        uint16 bytesPerScanLine;
  944. X/*------------ Optional ------------*/
  945. X        uint16 width;
  946. X        uint16 height;
  947. X        uint8 charWidth;
  948. X        uint8 charHeight;
  949. X        uint8 numberOfPlanes;
  950. X        uint8 bitsPerPixel;
  951. X        uint8 numberOfBanks;
  952. X        uint8 memoryModel;
  953. X        uint8 sizeOfBank;
  954. X    };
  955. X    uint8 filler[512];
  956. X} vesaModeInfo;
  957. X
  958. X//---------------------------------------------------
  959. X/*
  960. X*/
  961. X
  962. Xextern void setVGAColor(int16 index, int16 r, int16 g, int16 b);
  963. Xextern void setVGAPalette(palette *p);
  964. Xextern boolean getVesaInfo(vesaInfo *infoPtr);
  965. Xextern void printVesaInfo(FILE *file, vesaInfo *info);
  966. Xextern boolean getVesaModeInfo(int16 mode, vesaModeInfo *infoPtr);
  967. Xextern void printVesaModeInfo(FILE *file, vesaModeInfo *info);
  968. Xextern boolean setVesaMode(int16 mode);
  969. Xextern boolean getVesaMode(int16 *mode);
  970. Xextern boolean getVesaStateSize(uint8 flags, int32 *size);
  971. Xextern boolean getVesaState(uint8 flags, uint8 *buffer);
  972. Xextern boolean setVesaState(uint8 flags, uint8 *buffer);
  973. Xextern boolean setVesaWinAAddr(uint16 addr);
  974. Xextern boolean setVesaWinBAddr(uint16 addr);
  975. Xextern boolean getVesaWinAAddr(uint16 *addr);
  976. Xextern boolean getVesaWinBAddr(uint16 *addr);
  977. Xextern boolean setVesaScanLineLength(uint16 length);
  978. Xextern boolean getVesaScanLineLength(uint16 *bytesPerScanLine, 
  979. X                     uint16 *pixelsPerScanLine, 
  980. X                     uint16 *maxScanLines);
  981. Xextern boolean setVesaDisplayStart(uint16 pixel, uint16 line);
  982. Xextern boolean getVesaDisplayStart(uint16 *pixel, uint16 *line);
  983. X
  984. X#endif
  985. END_OF_FILE
  986.   if test 2626 -ne `wc -c <'vesa.h'`; then
  987.     echo shar: \"'vesa.h'\" unpacked with wrong size!
  988.   fi
  989.   # end of 'vesa.h'
  990. fi
  991. echo shar: End of archive 1 \(of 1\).
  992. cp /dev/null ark1isdone
  993. MISSING=""
  994. for I in 1 ; do
  995.     if test ! -f ark${I}isdone ; then
  996.     MISSING="${MISSING} ${I}"
  997.     fi
  998. done
  999. if test "${MISSING}" = "" ; then
  1000.     echo You have the archive.
  1001.     rm -f ark[1-9]isdone
  1002. else
  1003.     echo You still must unpack the following archives:
  1004.     echo "        " ${MISSING}
  1005. fi
  1006. exit 0
  1007.